//
//  Robost_Function.hpp
//  markerARLib
//
//  Created by CvidKal on 16/4/12.
//  Copyright © 2016年 CvidKal. All rights reserved.
//

#ifndef Robost_Function_hpp
#define Robost_Function_hpp

#include <stdio.h>
#include <Eigen/Dense>
/*
  * \brief base class for all Robust Functions
  *
  * Note in all kinds of robust function, e in the function corresponding to squared error.
  *
*/


class RobustKernel
{
public:
  explicit RobustKernel(double delta):_delta(delta){};
  virtual ~RobustKernel(){};
  
  /*
   * rho is the robustify value of e.
   * rho[0] is the robustify value rho
   * rho[1] is the first derivative of robust function
   * rho[2] is the second derivative of robust function
  */
  
  virtual void robustify(const double squaredError,Eigen::Vector3f& rho) = 0;
  double delta(){return _delta;}
  void setDelta(double delta){_delta = delta;};
protected:
  double _delta;
  
};


class RobustKernelHuber : public RobustKernel
{
public:
    RobustKernelHuber(double delta):RobustKernel(delta){};
  void robustify(const double e2,Eigen::Vector3f & rho);
};








#endif /* Robost_Function_hpp */
